<template>
    <div>
        <h1>添加</h1>
        <table class="table table-bordered">
            <tbody>
                
                 <tr>
                    <td>价格</td>
                    <td><input type="text" v-model="info.Housenum"></td>
                </tr>
                  <tr>
                    <td>数量</td>
                    <td><input type="text" v-model="info.breaknum"></td>
                </tr>
                 <tr>
                    <td>早餐</td>
                    <td><input type="text" v-model="info.Price"></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button" value="添加" @click="add"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref,onMounted } from 'vue';
import axios from 'axios';
import moment from 'moment';
import router from '@/router';

let info:any=ref({
  "id": 0,
  "Housenum": "",
  "breaknum": "",
  "Price": "",
})

const add=()=>{
    if(info.value.Housenum==""){
        alert("价格不能为空");
        return;
    }
     if(info.value.breaknum==""){
        alert("数量不能为空");
        return;
    }
     if(info.value.Price==""){
        alert("早餐不能为空");
        return;
    }
    axios({
        url:'https://localhost:7058/api/Price/AddP',
        method:'post',
        data:info.value
    })
    .then((res)=>{
        console.log(res);
        if(res.data>0){
            alert("添加成功")
            location.href='/HouseShow'
        }
        
    })
    .catch((err)=>{
        console.log(err);
    })
}
</script>

<style scoped>

</style>